CREATE TABLE test_order
(
	id					INTEGER,
	start_dttm	DATE,
	end_dttm		DATE,
	customer_id	INTEGER,
	price				NUMBER,
	CONSTRAINT  test_order_pk PRIMARY KEY(id)
);

CREATE TABLE test_customer
(
	id					INTEGER,
	name				VARCHAR2(128),
	CONSTRAINT  test_order_detail_pk PRIMARY KEY(id)
);

CREATE TABLE test_cdcv
(
	order_id			INTEGER,
	duration			NUMBER,
	price					NUMBER,
	customer_id		INTEGER,
	customer_name	VARCHAR2(128),
	CONSTRAINT  	test_cdcv_pk PRIMARY KEY(order_id)
);

CREATE INDEX test_cdcv_cid_idx
	ON test_cdcv(customer_id ASC);


INSERT INTO test_customer(id, name) VALUES(1, 'Apples');
INSERT INTO test_customer(id, name) VALUES(2, 'Oranges');
INSERT INTO test_customer(id, name) VALUES(3, 'Melons');

INSERT INTO test_order(id, start_dttm, end_dttm, customer_id, price) VALUES(1, SYSDATE-1.4, SYSDATE+1.3, 1, 20);
INSERT INTO test_order(id, start_dttm, end_dttm, customer_id, price) VALUES(2, SYSDATE-1.5, SYSDATE+1.4, 2, 30);
INSERT INTO test_order(id, start_dttm, end_dttm, customer_id, price) VALUES(3, SYSDATE-1.6, SYSDATE+1.5, 3, 40);

COMMIT;